package com.huike.controller.system;

import java.util.List;
import java.util.stream.Collectors;

import com.huike.common.annotation.PreAuthorize;
import com.huike.domain.system.SysRole;
import com.huike.domain.system.SysUser;
import com.huike.domain.system.dto.LoginUser;
import com.huike.utils.BcryptUtils;
import com.huike.web.CurrentUserHolder;
import com.huike.utils.ServletUtils;
import com.huike.utils.StringUtils;
import com.huike.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.huike.service.ISysRoleService;
import com.huike.service.ISysUserService;
import com.huike.common.annotation.Log;
import com.huike.common.constant.UserConstants;
import com.huike.controller.core.BaseController;
import com.huike.domain.common.AjaxResult;
import com.huike.page.TableDataInfo;
import com.huike.common.enums.BusinessType;
import com.huike.web.service.TokenService;

/**
 * 用户信息
 * 提示：用户的导入导出、生成模板需要操作Excel，见ExcelUtil
 */
@Api(tags = "用户管理")
@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController {

    @Autowired
    private ISysUserService userService;

    @Autowired
    private ISysRoleService roleService;


    @Autowired
    private TokenService tokenService;

    /**
     * 获取用户列表
     */
    @ApiOperation("用户管理-列表查询")
    @PreAuthorize("system:user:list")
    //@GetMapping("/list")
    public TableDataInfo list(SysUser user) {
        startPage(); //设置分页参数

        return null;
    }


    /**
     * 非权限下拉列表支持
     * @param user
     * @return
     */
    @ApiOperation("用户管理-用户下拉列表查询")
    //@GetMapping("/listselect")
    public AjaxResult listselect(SysUser user) {
        return null;
    }


    @ApiOperation("用户管理-导出")
    @Log(title = "用户管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("system:user:export")
    //@GetMapping("/export")
    public AjaxResult export(SysUser user) {

        return null;
    }

    @ApiOperation("用户管理-导入")
    @Log(title = "用户管理", businessType = BusinessType.IMPORT)
    @PreAuthorize("system:user:import")
    //@PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
        return null;
    }

    @ApiOperation("用户管理-生成模板")
    //@GetMapping("/importTemplate")
    public AjaxResult importTemplate() {
        return null;
    }

    /**
     * 根据用户编号获取详细信息
     */
    @ApiOperation("用户管理-详情查询")
    @PreAuthorize("system:user:query")
    //@GetMapping(value = {"/", "/{userId}"})
    public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
        return null;
    }

    /**
     * 新增用户
     */
    @ApiOperation("用户管理-新增")
    @PreAuthorize("system:user:add")
    @Log(title = "用户管理", businessType = BusinessType.INSERT)
    //@PostMapping
    public AjaxResult add(@Validated @RequestBody SysUser user) {
        return null;
    }

    /**
     * 修改用户
     */
    @ApiOperation("用户管理-修改")
    @PreAuthorize("system:user:edit")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    //@PutMapping
    public AjaxResult edit(@Validated @RequestBody SysUser user) {
        return null;
    }

    /**
     * 删除用户
     */
    @ApiOperation("用户管理-删除")
    @PreAuthorize("system:user:remove")
    @Log(title = "用户管理", businessType = BusinessType.DELETE)
    //@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds) {
        return null;
    }

    /**
     * 重置密码
     */
    @ApiOperation("用户管理-重置密码")
    @PreAuthorize("system:user:resetPwd")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    //@PutMapping("/resetPwd")
    public AjaxResult resetPwd(@RequestBody SysUser user) {
        return null;
    }

    /**
     * 状态修改
     */
    @ApiOperation("用户管理-修改状态")
    @PreAuthorize("system:user:edit")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    //@PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody SysUser user) {
        return null;
    }
}
